<template>
  <div v-if="visible" class="jump-dialog">
    <div class="jump-mask"></div>
    <div class="jump-content">
      <div class="dialog-content">
        <img class="jump-bg" src="@/assets/images/jump_bg.png" alt="" />
        <div class="jump-title flex flex-center">
          {{ props.title }}
        </div>
        <div class="jump-list">
          <div class="jump-item flex" v-for="(jump, idx) in props.list" :key="idx">
            <div class="jump-label flex flex-start flex-shrink">
              <img class="jump-icon" :src="jump.icon" alt="" />
              <div class="jump-text flex-shrink font-500">{{ jump.text }}</div>
            </div>
            <img class="jump-line" src="@/assets/images/line.png" alt="" />
            <div class="jump-amount flex flex-end font-500">{{ jump.amount }}</div>
          </div>
        </div>
        <div class="jump-split"></div>
        <div class="jump-bottom flex">
          {{ props.content }}
        </div>
      </div>
      <img class="dialog-close" src="@/assets/images/icon_close.png" alt="" @click="closeDialog" />
    </div>
  </div>
</template>
<script setup lang="ts">
import type { JumpDiscountItem } from '@/types/mall'
import { ref } from 'vue'

interface JumpDialogProps {
  title?: string
  list?: JumpDiscountItem[]
  content?: string
}
const visible = ref(false)
const props = withDefaults(defineProps<JumpDialogProps>(), {})
const openDialog = () => {
  visible.value = true
}
const closeDialog = () => {
  visible.value = false
}
defineExpose({
  openDialog,
  closeDialog,
})
</script>
<style lang="scss" scoped>
.jump-dialog {
  position: relative;
  z-index: 9999;
}
.jump-mask {
  width: 100vw;
  height: 100vh;
  background: #343434;
  opacity: 0.64;
  position: fixed;
  left: 0;
  top: 0;
}
.jump-content {
  position: fixed;
  z-index: 999;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 272px;
  background: #fff;
  border-radius: 8px;
}
.dialog-content {
  position: relative;
  .jump-bg {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    z-index: 0;
  }
  .jump-title {
    color: #fff;
    font-size: 16px;
    position: relative;
    height: 50px;
    z-index: 1;
  }
  .jump-list {
    margin-top: 64px;
    padding: 20px 0;
    box-sizing: border-box;
    position: relative;
    z-index: 1;
    min-height: 92px;
    .jump-item {
      padding: 0 40px;
      box-sizing: border-box;
    }
    .jump-item + .jump-item {
      margin-top: 12px;
    }
    .jump-label {
      flex: 4;
    }
    .jump-icon {
      width: 20px;
      height: 20px;
      margin-right: 6px;
    }
    .jump-text {
      font-size: 14px;
    }
    .jump-line {
      width: 50px;
    }
    .jump-amount {
      flex: 3;
      font-size: 14px;
    }
  }
  .jump-split {
    width: 182px;
    height: 2px;
    background: #dad7e3;
    opacity: 0.25;
    margin: 0 auto;
  }
  .jump-bottom {
    position: relative;
    z-index: 1;
    color: #952414;
    font-size: 12px;
    font-weight: 800;
    padding: 15px 0;
  }
}
.dialog-close {
  position: absolute;
  left: 50%;
  bottom: -59px;
  transform: translateX(-50%);
  width: 29px;
  height: 29px;
}
</style>
